(function ($) { $(document).ready(function () { var windowWidth = $(window).width(); // Set character limit restriction on column H3 headings // ------------------------------------------------------- setTimeout(function() { // Adjust as required by client const maxLength = 36; $('.styled-column h3.wp-block-heading').on('keydown', function(e) { const currentText = $(this).text(); // If the characters being entered is more than the maximum length if (currentText.length > maxLength) { // If key press is NOT backspace, prevent further input if (event.keyCode !== 8) { e.preventDefault(); } } }); }, 1000) $('.site-header__login-button').click(function() { $('.site-header__login-form').slideToggle('fast'); }); $('.login-close').click(function() { $('.site-header__login-form').slideToggle('fast'); }); // Header reorganization for mobile $(window).resize(function() { var windowWidth = $(window).width(); if (windowWidth < 1140) { $('.language-container').appendTo('.mega-toggle-blocks-left'); $('.site-header .site-header__login-button').appendTo('.mega-toggle-blocks-right'); } else { $('.language-container').prependTo('.header-actions'); $('.site-header .site-header__login-button').appendTo('.site-header--first-row > .wp-block-group'); } }); if (windowWidth < 1140) { $('.language-container').appendTo('.mega-toggle-blocks-left'); $('.site-header .site-header__login-button').appendTo('.mega-toggle-blocks-right'); } else { $('.language-container').prependTo('.header-actions'); $('.site-header .site-header__login-button').appendTo('.site-header--first-row > .wp-block-group'); } // Loop through each .cta-link column $('.cta-link').each(function() { // Find the link inside the column var link = $(this).find('a.wp-block-button__link').attr('href'); // Append the link to the parent .cta-link column if (link.length) { $(this).attr('data-link', link); } }); // Make the .cta-link column clickable $('.cta-link').on('click', function() { // Get the link from the data-link attribute var link = $(this).attr('data-link'); // Redirect to the link if it exists if (link) { window.location.href = link; } }); // sliders function initializeSlick() { $('.info-cards-slider').each(function () { const $sliderWrapper = $(this); const $slider = $sliderWrapper.find('.slider'); const $pagination = $sliderWrapper.find('.custom-dots'); const $arrowsContainer = $sliderWrapper.find('.slider-controls .custom-pagination'); if ($slider.length) { // Initialize the slider $slider.on('init', function (event, slick) { updatePagination(slick, 0); // Display initial pagination }); $slider.slick({ slidesToShow: 3, slidesToScroll: 3, arrows: true, dots: false, autoplay: false, appendArrows: $arrowsContainer, responsive: [ { breakpoint: 783, settings: { slidesToShow: 1, slidesToScroll: 1, } }, { breakpoint: 1025, settings: { slidesToShow: 2, slidesToScroll: 2, } } ] }); // Update pagination on slide change $slider.on('afterChange', function (event, slick, currentSlide) { updatePagination(slick, currentSlide); }); // Function to update pagination for this slider only function updatePagination(slick, currentSlide) { const totalSlides = Math.ceil(slick.slideCount / slick.options.slidesToScroll); const currentPage = Math.floor(currentSlide / slick.options.slidesToScroll) + 1; $pagination.text(`${currentPage} of ${totalSlides}`); } } }); if ($('.realated-content-slider .slider').length) { // Initialize the slider $('.realated-content-slider .slider').on('init', function (event, slick) { updatePagination(event, slick, 0); // Display initial pagination }); $('.realated-content-slider .slider').slick({ slidesToShow: 3, slidesToScroll: 3, arrows: true, dots: false, autoplay: false, appendArrows: $('.realated-content-slider .slider-controls .custom-pagination'), responsive: [ { breakpoint: 783, settings: { slidesToShow: 1, slidesToScroll: 1, } }, { breakpoint: 1025, settings: { slidesToShow: 2, slidesToScroll: 2, } } ] }); // Update pagination on slide change $('.realated-content-slider .slider').on('afterChange', function (event, slick, currentSlide) { updatePagination(event, slick, currentSlide); }); // Function to update the pagination function updatePagination(event, slick, currentSlide) { const totalSlides = Math.ceil(slick.slideCount / slick.options.slidesToScroll); const currentPage = Math.floor(currentSlide / slick.options.slidesToScroll) + 1; $('.realated-content-slider .custom-dots').text(`${currentPage} of ${totalSlides}`); } } } // Initialize Slick on document ready initializeSlick(); $('.grid-filter-categories, .grid-filter-tags').chosen(); $('.grid-filter-categories, .grid-filter-tags').change(function () { let selectedCategories = $('.grid-filter-categories').val(); // Get value of categories let selectedTags = $('.grid-filter-tags').val(); // Get value of tags // console.log('Selected Categories:', selectedCategories); // console.log('Selected Tags:', selectedTags); var ajaxurl = '/wp-admin/admin-ajax.php'; $.ajax({ url: ajaxurl, type: 'POST', data: { action: 'filter_grid_news', categories: selectedCategories, tags: selectedTags, }, success: function (response) { // console.log(response); $('.filter-grid-news').html(response); }, }); }); // Site search popup var searchIcon = $('.search-icon'); searchIcon.click(function() { $('.search-dropdown').slideToggle('fast'); }); $('.search-close').click(function () { $('.search-dropdown').slideToggle('fast'); }); if (windowWidth < 1140) { searchIcon.appendTo('.site-header--first-row > .wp-block-group .header-actions'); } $(window).resize(function() { var windowWidth = $(window).width(); if (windowWidth < 1140) { searchIcon.appendTo('.site-header--first-row > .wp-block-group .header-actions'); } else { searchIcon.appendTo('#mega-menu-max_mega_menu_1 .mega-nav-search .mega-menu-link'); } }); // Add class to control image column order on mobile $('.wp-block-column').each(function() { // Check if the current .wp-block-column contains a
element if ($(this).find('figure').length > 0) { // Add the 'has-media' class to the .wp-block-column element $(this).addClass('has-media'); } }); // Removes active mega menu style when a different tab is hovered, then re-applies it again setTimeout(function() { $('#mega-menu-max_mega_menu_1 > li > a').hover(function() { const activeItem = $('.mega-current-menu-ancestor'); $('#mega-menu-max_mega_menu_1 > li > a').css({'background':'transparent'}); $(this).css({'background':'#f7f7f7'}); }, function() { $(this).css({'background':'transparent'}); const activeItem = $('.mega-current-menu-ancestor'); activeItem.children('a').css({'background':'#f7f7f7'}); }); }, 100); // Password visibility functionality // ------------------------------------------------------- $(".toggle-password").click(function () { let passwordField = $(".password-wrapper input"); let fieldType = passwordField.attr("type") === "password" ? "text" : "password"; passwordField.attr("type", fieldType); // Toggle the icon class between fa-eye and fa-eye-slash $(this).find('i').toggleClass("fa-eye fa-eye-slash"); }); // Understanding My Bill image hotspot graphic // ------------------------------------------------------- $('.bill-pay-graphic-item').each(function(index) { const indexNumber = index+1; const item = '.bill-pay-graphic-item--'+indexNumber; $(item).find('.wp-block-button').each(function(index) { $(this).click(function() { const itemNumber = index+1; $('.bill-pay-graphic-wrapper .wp-block-button').removeClass('show-border'); $(this).addClass('show-border'); // alert(item); $(item).find('.bill-info').hide(); $(item).find('.bill-info--'+itemNumber).show(); }); }); $(item).find('.bill-info .prev-btn').click(function() { $('.bill-info').hide(); const currentItem = $(this).closest('.bill-info'); const previousItem = currentItem.prev('.bill-info'); if (previousItem.length > 0) { let parentIndex = currentItem.index(item + ' .bill-info'); currentItem.hide(); previousItem.show(); // Find the corresponding circle icon let $activeCircle = $(item).find('.circle--' + parentIndex); $activeCircle.click(); // Trigger click on the active circle // Scroll smoothly to bring the active circle into view const wWidth = $(window).width(); if (wWidth > 1340) { $("html, body").animate({ scrollTop: $activeCircle.offset().top - 150 // Adjust offset for visibility }, 500); } } }); $(item).find('.bill-info .next-btn').click(function() { $('.bill-info').hide(); const currentItem = $(this).closest('.bill-info'); const nextItem = currentItem.next('.bill-info'); if (nextItem.length > 0) { let parentIndex = nextItem.index(item + ' .bill-info') + 1; currentItem.hide(); nextItem.show(); // Find the corresponding circle icon let $activeCircle = $(item).find('.circle--' + parentIndex); $activeCircle.click(); // Trigger click on the active circle // Scroll smoothly to bring the active circle into view const wWidth = $(window).width(); if (wWidth > 1340) { $("html, body").animate({ scrollTop: $activeCircle.offset().top - 150 // Adjust offset for visibility }, 500); } } }); }); $('.bill-pay-graphic-wrapper .mobile-img').click(function() { $('.bill-info--1').fadeIn('fast'); }); $('.bill-info--close').click(function() { $('.bill-info').hide(); }); $('.bill-dropdown').change(function() { const graphicTarget = $(this).find(':selected').data('target'); $('.bill-pay-graphic-item').hide(); $('.bill-info').hide(); // Hide all .bill-info elements before showing the correct one const $targetItem = $('.' + graphicTarget); $targetItem.show(); // Ensure the first .bill-info in the shown item is visible $targetItem.find('.bill-info').first().show(); // Find and trigger click on the first circle item const $firstCircle = $targetItem.find('.circle--1'); if ($firstCircle.length) { $firstCircle.click(); } }); // Responsive tables // ------------------------------------------------------- $('table thead th').each(function (index) { const label = $(this).text(); $('table thead + tbody tr').each(function () { $(this).find('td').eq(index).attr('data-label', label); }); }); // Only allow one mobile menu to be expanded at a time if (windowWidth < 1140) { const menuItems = document.querySelectorAll('.mega-menu-item'); menuItems.forEach((menuItem) => { menuItem.addEventListener('click', (e) => { menuItems.forEach((item) => { item.classList.remove('mega-toggle-on'); }); menuItem.classList.add('mega-toggle-on'); }); }); } }); })(jQuery);